function LeftNav(){
	this.init();
}
//html模板
LeftNav.NavTemplate=`
  <p>功能列表
	  <a class="list-p" href="javascript:;">
	    <img src="/images/tianjia.png"></img>
	  </a>
  </p>
  <ul class="list">
    <li class="list-bg">
    <img src="/images/zd.png"></img>
    <a href="/html/count.html">账单管理</a>
    </li>
    <li>
    <img src="/images/gys.png"></img>
    <a href="/html/provider.html">供应商管理</a>
    </li>
    <li>
    <img src="/images/yh.png"></img>
    <a href="/html/usergl.html">用户管理</a>
    </li>
    <li>
    <img src="/images/mm.png"></img>
    <a href="/html/psd.html">密码修改</a>

    </li>
    <li>
    <img src="/images/tc.png"></img>
    <a class="exit" href="/html/exit.html">退出系统</a>
    </li>
  </ul>
</div>`;
$.extend(LeftNav.prototype,{
	init(){
	this.createDom();
	this.addListener();
	},
	//创建DOM
	createDom(){
		$(".left_nav").html(LeftNav.NavTemplate);
	},
	//注册事件监听
	addListener(){
		$(".list").on("click","a",$.proxy(this.listHandler,this));
// <<<<<<< HEAD
        $(".exit").on("click",this.exitHandler);
		console.log(this);
// =======
		//console.log(this);
// >>>>>>> a0a2f0b29f86a3c12ec7ce539353068cce17158b
	},
	listHandler(event){
		const $src = $(event.target);
		$src.parent("li").addClass("list-bg").siblings("li").removeClass("list-bg");		
	},
    // 退出系统，注销用户，返回登录界面
    exitHandler() {
        sessionStorage.removeItem("username");
        $.getJSON("/api/users/logout",(data)=>{
            if(data.res_body.status===1){
                //location.reload();
                window.location.href='/html/login.html';
            }
        })
    }
});
new LeftNav();